﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq;

namespace Abhar.web.src
{
    public static class NewsExtentions
    {
        public static News GetTopNews(this Table<News> news)
        {
            return news.FirstOrDefault(n => n.IsTopNews);
        }

        public static News GetById(this Table<News> news, int Id) 
        {
            return news.SingleOrDefault(n => n.Id == Id);
        }

        public static IEnumerable GetTopXArabic(this Table<News> news, int x)
        {
            return news.Take(x).Select(n => new {Id = n.Id, Title = n.TitleAr, Description = n.DescriptionAr, ImgUrl = n.ImgUrl});
        }
        public static IEnumerable GetTopXEnglish(this Table<News> news, int x)
        {
            return news.Take(x).Select(n => new { Id = n.Id, Title = n.TitleEn, Description = n.DescriptionEn, ImgUrl = n.ImgUrl });
        }
    }
}